#include<bits/stdc++.h>
using namespace std;
int a[100010],d[100010],v[100010];
int ans;
int q[100010];
vector<int>o[3010];int c[3011],b[3011];
int main(){
   freopen("detect.in","r",stdin);
 freopen("detect.out","w",stdout);
int t;
cin>>t;
while(t--){int y=0;
        ans=0;
memset(a,0,sizeof(a));
memset(d,0,sizeof(d));
memset(v,0,sizeof(v));
memset(q,0,sizeof(q));
memset(o,0,sizeof(o));
memset(o,0,sizeof(c));
memset(o,0,sizeof(b));
    int n,m,L,V;
cin>>n>>m>>L>>V;
for(int i=1;i<=n;i++){
    int h;
    cin>>h>>v[i]>>a[i];
q[i]=h;
}
for(int i=1;i<=m;i++){cin>>d[i];

}bool flag=0;
for(int i=1;i<=n;i++){   long long s=V*V-v[i]*v[i];
        if(a[i]==0){
                if(v[i]>V){ans++;//cout<<i<<endl;
                y++;
                b[i]++;

                }
        }

    else if(a[i]>0){flag=1;
      for(int j=1;j<=m;j++){
        if(d[j]>=q[i]&&(d[j]-q[i])*2*a[i]>s){ b[i]++;
                o[j].push_back(i);
            ans++;//cout<<i<<endl;
            break;
        }
      }
}
else{double r=-1*v[i]*v[i]*1.0/(2*a[i]);
flag=1;
      for(int j=1;j<=m;j++){
        if(d[j]>=q[i]&&(d[j]-q[i])*2*a[i]>s&&d[j]-q[i]<=r){ b[i]++;
                o[j].push_back(i);
            ans++;//cout<<i<<" "<<j<<endl;
            break;
        }
      }
}
}
if(flag==0)cout<<ans<<" "<<m-1<<endl;
else{long long sum=0;
for(int i=1;i<=m;i++){
sum+=o[i].size();
}
cout<<ans<<" "<<max(ans-1,ans+n-m)<<endl;
}
}}
